home *** CD-ROM | disk | FTP | other *** search
-
- ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
- ///
- /// Some stupid routines :) <
- ///
- ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
- ///
- /* ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¯
- ¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¥ IntuiRefresh() ª¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¯
- ¢ ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡´ ¢
- ¢ See for moving reqtools requestrers and refresh program windows which are ¢
- ¢ trashed by ones. ¢
- ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡´
- */
- void __saveds __asm IntuiRefresh (REG(a0) struct Hook *hook, REG(a2) struct rtReqInfo *reqinfo, REG(a1) struct IntuiMessage *imsg)
- {
- if (imsg->Class == IDCMP_REFRESHWINDOW)
- DoMethod (AmiMirrorPrefs, MUIM_Application_CheckRefresh);
- }
- ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
- ///
- ULONG __stdargs DoSuperNew (struct IClass *cl, Object *obj, ULONG tag1,...)
- {
- return (DoSuperMethod (cl, obj, OM_NEW, &tag1, NULL));
- }
- ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
- ///
- // get atribute of an object
-
- LONG xget (Object *obj, ULONG attribute)
- {
- LONG x;
- get (obj, attribute, &x);
- return (x);
- }
- ///¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ <
- ///
- // get string pointer of an string object
-
- STRPTR getstr (Object *obj)
- {
- return ((STRPTR)xget (obj,MUIA_String_Contents));
- }
- //--------------------------------------------------------------------
- // Make program's message with EasyRequest() or MUI_Request()
-
- LONG MakeRequest (ULONG title, ULONG text, ULONG buttons, APTR arg1, ...)
- {
- UBYTE txt_buf[MSG_MAXSIZE];
-
- struct EasyStruct es = { sizeof(struct EasyStruct), 0L, NULL, NULL, NULL };
-
- if (AmiMirrorPrefs)
- {
- RDF (txt_buf, MUI_TEXTCENTER_FMT, (ULONG)GETMES(text));
- return (MUI_RequestA (AmiMirrorPrefs, MainWin, 0, GETMES(title), GETMES(buttons), txt_buf, &arg1));
- }
- es.es_Title = GETMES(title);
- es.es_TextFormat = GETMES(text);
- es.es_GadgetFormat = GETMES(buttons);
- DisplayBeep (NULL);
- return (EasyRequestArgs (NULL, &es, NULL, &arg1));
- }
- //--------------------------------------------------------------------
- // Translate DOS-error code into descriptor string
-
- STRPTR FaultStr (LONG error)
- {
- Fault (error, GETMES(DOS_ERROR_STR), dosfault, 2*FAULT_MAX);
- return (dosfault);
- }
- //--------------------------------------------------------------------
- // Convert array of ULONGs into array of STRPTRs
-
- void FillIt (VAGUE *array1, ...)
- {
- ULONG count;
- VAGUE *a;
- VAGUE **pa = &array1;
-
- while (a = *pa++)
- {
- for (count = 0L; a[count].num; count++)
- a[count].str = GETMES(a[count].num);
- }
- }
- //--------------------------------------------------------------------
- // Build list of XPK packers
-
- BOOL GetXpkList (void)
- {
- if (! XL)
- XL = (struct XpkPackerList *) XpkAllocObject (XPKOBJ_PACKERLIST, 0);
- if (XL)
- {
- if (! (XpkQueryTags (XPK_PackersQuery, XL, XPK_Preferences, FALSE, TAG_DONE)))
- return (TRUE);
- }
- MakeRequest (REQ_TITLE_ERROR, XPK_NOLIST_ERROR, CANCEL_BUT, NULL);
- return (FALSE);
- }
-
- //--------------------------------------------------------------------
- // Get information about packer
-
- BOOL GetXpkInfo (STRPTR method)
- {
- if (method)
- {
- if (! XI)
- XI = (struct XpkPackerInfo *) XpkAllocObject (XPKOBJ_PACKERINFO, 0);
- if (XI)
- {
- if (! (XpkQueryTags (XPK_PackerQuery, XI, XPK_PackMethod, method, TAG_DONE)))
- return (TRUE);
- }
- MakeRequest (REQ_TITLE_ERROR, XPK_NOINFO_ERROR, CANCEL_BUT, method);
- }
- return (FALSE);
- }
- //--------------------------------------------------------------------
- // - Get additional information about packer
-
- BOOL GetXpkMode (STRPTR method, ULONG mode)
- {
- if (method)
- {
- if (! XM)
- XM = (struct XpkMode *) XpkAllocObject (XPKOBJ_MODE, 0);
- if (XM)
- {
- if (! (XpkQueryTags (XPK_ModeQuery, XM,
- XPK_PackMethod, method,
- XPK_PackMode, mode, TAG_DONE)))
- return (TRUE);
- }
- MakeRequest (REQ_TITLE_ERROR, XPK_NOINFO_ERROR, CANCEL_BUT, method);
- }
- return (FALSE);
- }
- //--------------------------------------------------------------------
- // Realise the memory allocated for the patterns' list
-
- void FreePatList (struct List *list)
- {
- struct Node *node;
-
- while (node = RemTail (list))
- FreeVec (node);
- FreeVec (list);
- }
- //--------------------------------------------------------------------
- // Load settings (patterns' list)
-
- BOOL LoadSets (STRPTR filename, struct List *list)
- {
- struct PatternNode *PN;
- struct SetsHeader SH;
- struct PatternHeader PH;
- BPTR SetsFH;
- BOOL convert = FALSE, result = GAME_OVER;
-
- if (SetsFH = Open (filename, MODE_OLDFILE))
- {
- if (Read (SetsFH, &SH, sizeof(struct SetsHeader)) == sizeof(struct SetsHeader))
- {
- if (SH.sh_ID == SETS_ID)
- {
- if (SH.sh_version <= SETS_VERSION)
- {
- if (SH.sh_version < SETS_VERSION)
- convert = TRUE;
- if (SH.sh_amount > 0L)
- {
- result = ALL_RIGHT;
- while (SH.sh_amount--)
- {
- if (PN = AllocVec (sizeof(struct PatternNode), MEMF_PUBLIC | MEMF_CLEAR))
- {
- if ((Read (SetsFH, &PH, sizeof(struct PatternHeader)) != sizeof(struct PatternHeader)) ||
- (Read (SetsFH, PN->pn_Pattern, PH.ph_PatternSize) != PH.ph_PatternSize) ||
- (Read (SetsFH, PN->pn_Storage, PH.ph_StorageSize) != PH.ph_StorageSize) ||
- (Read (SetsFH, PN->pn_Password, PH.ph_PasswordSize) != PH.ph_PasswordSize))
- {
- FreeVec (PN);
- if (MakeRequest (REQ_TITLE_ERROR, CANT_READ_SETS, CANCEL_CONTINUE_BUT, filename, FaultStr (IoErr())))
- result = GAME_OVER;
- break;
- }
- if (convert)
- PN->pn_Function = 0;
- else
- PN->pn_Function = PH.ph_Function;
- PN->pn_PatternMode = PH.ph_PatternMode;
- PN->pn_StorageMode = PH.ph_StorageMode;
- PN->pn_StorageMethod = PH.ph_StorageMethod;
- PN->pn_PerformCheck = PH.ph_PerformCheck;
- if (PN->pn_UseXPK = PH.ph_UseXPK)
- {
- strcpy (PN->pn_XPKName, PH.ph_XPKName);
- PN->pn_XPKMode = PH.ph_XPKMode;
- }
- PN->pn_Node.ln_Name = PN->pn_Pattern;
- AddTail (list, (struct Node *)PN);
- }
- else
- {
- MakeRequest (REQ_TITLE_ERROR, OUT_MEM, CANCEL_BUT, NULL);
- result = GAME_OVER;
- break;
- }
- }
- }
- else if (! MakeRequest (REQ_TITLE_ERROR, NOT_SETS_FILE, CANCEL_CONTINUE_BUT, filename))
- result = ALL_RIGHT;
- }
- else if (! MakeRequest (REQ_TITLE_ERROR, NOT_SETS_FILE, CANCEL_CONTINUE_BUT, filename))
- result = ALL_RIGHT;
- }
- else if (! MakeRequest (REQ_TITLE_ERROR, NOT_SETS_FILE, CANCEL_CONTINUE_BUT, filename))
- result = ALL_RIGHT;
- }
- else if (! MakeRequest (REQ_TITLE_ERROR, CANT_READ_SETS, CANCEL_CONTINUE_BUT, filename, FaultStr (IoErr())))
- result = ALL_RIGHT;
- Close (SetsFH);
- }
- else if (! MakeRequest (REQ_TITLE_ERROR, CANT_OPEN_SETS, CANCEL_CONTINUE_BUT, filename, FaultStr (IoErr())))
- result = ALL_RIGHT;
- return (result);
- }
- //--------------------------------------------------------------------
- // Save settings (patterns' list)
-
- void SaveSets (STRPTR filename, Object *plist)
- {
- struct PatternNode *PN;
- struct SetsHeader SH;
- struct PatternHeader PH;
- ULONG x;
- STRPTR str;
- BPTR SetsFH;
-
- if (SH.sh_amount = xget (plist, MUIA_List_Entries))
- {
- SH.sh_ID = SETS_ID;
- SH.sh_version = SETS_VERSION;
- if (SetsFH = Open (filename, MODE_NEWFILE))
- {
- if (Write (SetsFH, &SH, sizeof(struct SetsHeader)) == sizeof(struct SetsHeader))
- {
- for (x = 0L; x < SH.sh_amount; x++)
- {
- DoMethod (plist, MUIM_List_GetEntry, x, &str);
- if (str && (PN = (struct PatternNode *)FindName (PatList, str)))
- {
- PH.ph_Function = PN->pn_Function;
- PH.ph_PatternMode = PN->pn_PatternMode;
- PH.ph_StorageMode = PN->pn_StorageMode;
- PH.ph_StorageMethod = PN->pn_StorageMethod;
- PH.ph_PerformCheck = PN->pn_PerformCheck;
- PH.ph_PatternSize = strlen (PN->pn_Pattern);
- PH.ph_StorageSize = strlen (PN->pn_Storage);
- if (PH.ph_UseXPK = PN->pn_UseXPK)
- {
- strcpy (PH.ph_XPKName, PN->pn_XPKName);
- PH.ph_XPKMode = PN->pn_XPKMode;
- PH.ph_PasswordSize = strlen (PN->pn_Password);
- }
- else
- {
- PH.ph_XPKName[0] = PH.ph_XPKName[1] = PH.ph_XPKName[2] =
- PH.ph_XPKName[3] = PH.ph_XPKName[4] = PH.ph_XPKName[5] = '\0';
- PH.ph_XPKMode = PH.ph_PasswordSize = 0;
- }
- if ((Write (SetsFH, &PH, sizeof(struct PatternHeader)) != sizeof(struct PatternHeader)) ||
- (Write (SetsFH, PN->pn_Pattern, PH.ph_PatternSize) != PH.ph_PatternSize) ||
- (Write (SetsFH, PN->pn_Storage, PH.ph_StorageSize) != PH.ph_StorageSize) ||
- (Write (SetsFH, PN->pn_Password, PH.ph_PasswordSize) != PH.ph_PasswordSize))
- {
- MakeRequest (REQ_TITLE_ERROR, CANT_SAVE_SETS, CANCEL_BUT, filename, FaultStr (IoErr()));
- break;
- }
- }
- else
- {
- MakeRequest (REQ_TITLE_ERROR, CANT_GIVE_SETS, CANCEL_BUT, NULL);
- break;
- }
- }
- }
- else
- MakeRequest (REQ_TITLE_ERROR, CANT_SAVE_SETS, CANCEL_BUT, filename, FaultStr (IoErr()));
- Close (SetsFH);
- }
- else
- MakeRequest (REQ_TITLE_ERROR, CANT_OPEN_SETS, CANCEL_BUT, filename, FaultStr (IoErr()));
- }
- else
- MakeRequest (REQ_TITLE_ERROR, LIST_EMPTY_SETS, CANCEL_BUT, NULL);
- }
-